/**
 * PanelEstudiantes.java
 */

 /**
 *  AdSec: Administrador de Secundarias
 *  Copyright (C) 2009 Daniela Ramírez Chaves (dannyrch@gmail.com)
 *  Copyright (C) 2009 Leonel Salazar Valverde (leo87sv@gmail.com)
 *
 *  This file is part of AdSec.
 *  AdSec is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  AdSec is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with AdSec.  If not, see <http://www.gnu.org/licenses/>.
 */

package adsec.presentacion;


import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Date;
import java.util.Calendar;
import java.util.Iterator;
import java.util.LinkedList;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.ListSelectionModel;
import javax.swing.SpinnerNumberModel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.DefaultTableModel;
import javax.swing.text.MaskFormatter;
import adsec.entidades.Estado;
import adsec.entidades.Estudiante;
import adsec.entidades.Permiso;
import adsec.negocios.AdministradorSeguridad;
import adsec.negocios.ControladoraEstudiante;
import adsec.negocios.UtilidadesCapaNegocios;
import adsec.presentacion.UtilidadesPresentacion.ImageFileView;
import adsec.presentacion.UtilidadesPresentacion.ImageFilter;
import adsec.presentacion.UtilidadesPresentacion.ImagePreview;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import org.jdesktop.application.Action;


public class PanelEstudiantes extends javax.swing.JPanel implements ListSelectionListener, ChangeListener{

    private AdministradorSeguridad admSeguridad;
    private ControladoraEstudiante controladoraEstudiante;
    private Permiso permisoEstudiante;
    private Estado estado;
    private int MAX_TAMAÑO = (int)Math.pow(2, 24);

    /** Creates new form PanelEstudiantes */
    public PanelEstudiantes() {
        initComponents();
        //this.iniciarPanelEstudiantes();
    }

	public void stateChanged(ChangeEvent evento){
		if(evento.getSource() == this.spinAño ||
				evento.getSource() == this.spinMes ||
				evento.getSource() == this.spinDia){

			this.txtEdad.setText(Integer.toString(
					UtilidadesCapaNegocios.obtenerEdad(this.obtenerCalendarioFecha())));
		}
	}

    public void valueChanged(ListSelectionEvent e) {
        int filas = ((DefaultTableModel)this.gridEstudiantes.getModel()).getRowCount();
        if(filas > 0 && estado.getEstadoActual() == Estado.CONSULTAR && e.getValueIsAdjusting()){
            int fila = this.gridEstudiantes.getSelectedRow();
            if(fila >= 0){
                String cedula = this.gridEstudiantes.getModel().getValueAt(fila, 0).toString();
                this.consultarDatosEstudiante(cedula);
            }
        }
    }

    public void iniciarPanelEstudiantes(){
        this.admSeguridad = AdministradorSeguridad.getInstancia();
        this.controladoraEstudiante = new ControladoraEstudiante();
        this.permisoEstudiante = this.admSeguridad.getPermiso(UtilidadesCapaNegocios.moduloEstudiantes);
        this.estado = new Estado();
        this.limpiarCampos();
        this.setHabilitarCampos(false);
        this.habilitarBotonesIME(this.permisoEstudiante.isInsertar(), false, false);
        this.cargarGridEstudiantes();
        this.habilitarAceptarCancelar(false);
    }

    protected MaskFormatter createFormatter(String s) {
        MaskFormatter formatter = null;
        try {
            formatter = new MaskFormatter(s);
        } catch (java.text.ParseException exc) {
            System.err.println("formatter is bad: " + exc.getMessage());
            System.exit(-1);
        }
        return formatter;
    }

    /*
     *Recibe un boolean para habilitar todos los campos de la pantalla o ya se
     * deshabilitarlos
     */
    private void setHabilitarCampos(boolean habilitar){
        this.txtNombre.setEditable(habilitar);
        this.txtApellidos.setEditable(habilitar);
        this.txtCedula.setEditable(habilitar);
        this.spinDia.setEnabled(habilitar);
        this.spinMes.setEnabled(habilitar);
        this.spinAño.setEnabled(habilitar);
        this.cbSexo.setEnabled(habilitar);
        this.txtNacionalidad.setEditable(habilitar);
        this.txtEscuelaProcedencia.setEditable(habilitar);
        this.txtTelefono1.setEditable(habilitar);
        this.txtTelefono2.setEditable(habilitar);
        this.txtProvincia.setEditable(habilitar);
        this.txtCanton.setEditable(habilitar);
        this.txtDistrito.setEditable(habilitar);
        this.txtOtrasSeñas.setEditable(habilitar);
        this.btnExaminar.setEnabled(habilitar);
        this.cbAdeacuacion1.setEnabled(habilitar);
        this.cbAdeacuacion2.setEnabled(habilitar);
        this.txtProblemasSalud.setEditable(habilitar);
        this.txtCondSocioAfectiva.setEditable(habilitar);
        this.txtCondSocioeconomica.setEditable(habilitar);
    }

    /*
     * Habilita o deshabilita los botones insertar, modificar y eliminar
     */
    private void habilitarBotonesIME(boolean insertar, boolean modificar, boolean eliminar){
        this.btnInsertar.setEnabled(insertar);
        this.btnModificar.setEnabled(modificar);
        this.btnEliminar.setEnabled(eliminar);
    }

    private void habilitarAceptarCancelar(boolean habilitar){
        this.btnAceptar.setEnabled(habilitar);
        this.btnCancelar.setEnabled(habilitar);
    }

    private void limpiarCampos(){
        this.txtNombre.setText("");
        this.txtApellidos.setText("");
        this.txtCedula.setText("0-0000-0000");
        this.spinDia.getModel().setValue(1);
        this.spinMes.getModel().setValue(1);
        this.spinAño.getModel().setValue(1990);
        this.txtEdad.setText("");
        this.cbSexo.setSelectedIndex(0);
        this.txtNacionalidad.setText("");
        this.txtEscuelaProcedencia.setText("");
        this.txtTelefono1.setText("00-00-00-00");
        this.txtTelefono2.setText("00-00-00-00");
        this.txtProvincia.setText("");
        this.txtCanton.setText("");
        this.txtDistrito.setText("");
        this.txtOtrasSeñas.setText("");
        this.txtFotoUrl.setText("");
        this.cbAdeacuacion1.setSelectedIndex(0);
        this.cbAdeacuacion2.setSelectedIndex(0);
        this.txtProblemasSalud.setText("");
        this.txtCondSocioAfectiva.setText("");
        this.txtCondSocioeconomica.setText("");
        this.areaFoto.limpiarFoto();
    }

    /*
     * Método Insertar estudiante
     */
    private void insertarEstudiante(){
        Estudiante estudiante = obtenerDatosEstudiante();
        if(!UtilidadesCapaNegocios.existeLlave(Estudiante.nombreTabla, Estudiante.cedulaNC, estudiante.getCedula())){
            int resultado = this.controladoraEstudiante.insertarEstudiante(estudiante);
            if(resultado == UtilidadesCapaNegocios.QUERY_OK){
                FileInputStream foto = obtenerFoto();
                if(foto != null){
                    int resultadoFoto = this.controladoraEstudiante.insertarFotoEstudiante(foto, estudiante.getCedula());
                    if(resultadoFoto == UtilidadesCapaNegocios.QUERY_ERROR){
                        String mensaje = "No se pudo insertar la foto de estudiante";
                        JOptionPane.showMessageDialog(null, mensaje, "ERROR",JOptionPane.ERROR_MESSAGE);
                    }
                    this.cerrarFoto(foto);
                }
                this.gridEstudiantes.getSelectionModel().clearSelection();
                JOptionPane.showMessageDialog(null, "El estudiante fue insertado exitosamente");
                this.volverConsultar();
            }else{
                String mensaje = UtilidadesCapaNegocios.getErrorOperacion(UtilidadesCapaNegocios.moduloEstudiantes, UtilidadesCapaNegocios.opInsertar);
                JOptionPane.showMessageDialog(null, mensaje, "ERROR",JOptionPane.ERROR_MESSAGE);
            }
        }else{
            JOptionPane.showMessageDialog(null, "El estudiante con cédula " + estudiante.getCedula() + " ya existe", "ERROR", JOptionPane.ERROR_MESSAGE);
        }
    }

    private void modificarEstudiante(){
        Estudiante estudiante = obtenerDatosEstudiante();        
        int resultado = this.controladoraEstudiante.modificarEstudiante(estudiante);
        if(resultado == UtilidadesCapaNegocios.QUERY_OK){
            FileInputStream foto = obtenerFoto();
            if(foto != null){
                int resultadoFoto = this.controladoraEstudiante.modificarFotoEstudiante(foto, estudiante.getCedula());
                if(resultadoFoto == UtilidadesCapaNegocios.QUERY_ERROR){
                    String mensaje = "No se pudo insertar la foto de estudiante";
                    JOptionPane.showMessageDialog(null, mensaje, "ERROR",JOptionPane.ERROR_MESSAGE);
                }
                this.cerrarFoto(foto);
            }
            this.gridEstudiantes.getSelectionModel().clearSelection();
            JOptionPane.showMessageDialog(null, "El estudiante fue modificado exitosamente");
            this.volverConsultar();
        }else{
            String mensaje = UtilidadesCapaNegocios.getErrorOperacion(UtilidadesCapaNegocios.moduloEstudiantes, UtilidadesCapaNegocios.opModificar);
            JOptionPane.showMessageDialog(null, mensaje, "ERROR",JOptionPane.ERROR_MESSAGE);
        }
    }

    private void eliminarEstudiante(){
        String cedula = txtCedula.getText();
        int resultado = this.controladoraEstudiante.eliminarEstudiante(cedula);
        if(resultado == UtilidadesCapaNegocios.QUERY_OK){
            this.gridEstudiantes.getSelectionModel().clearSelection();
            JOptionPane.showMessageDialog(null, "El estudiante fue eliminado exitosamente");
            this.volverConsultar();
            this.limpiarCampos();
        }else{
            String mensaje = UtilidadesCapaNegocios.getErrorOperacion(UtilidadesCapaNegocios.moduloEstudiantes, UtilidadesCapaNegocios.opEliminar);
            JOptionPane.showMessageDialog(null, mensaje, "ERROR",JOptionPane.ERROR_MESSAGE);
        }
    }

    private FileInputStream obtenerFoto() {
        FileInputStream fotita = null;
        String dirFoto = txtFotoUrl.getText();
        if(!dirFoto.trim().isEmpty()){
             try{
                fotita = new FileInputStream(dirFoto);
             }catch(IOException e){
                e.printStackTrace();
             }
        }
        return fotita;
    }

    private boolean verificarTamañoFoto(){
        FileInputStream fotita = null;
        String dirFoto = txtFotoUrl.getText();
        int tamaño = 0;
        if(!dirFoto.trim().isEmpty()){
             try{
                fotita = new FileInputStream(dirFoto);
                tamaño = fotita.available();
                fotita.close();
             }catch(IOException e){
                e.printStackTrace();
             }
        }
        System.out.println(tamaño);
        return tamaño < MAX_TAMAÑO;
    }

    private void cerrarFoto(FileInputStream foto){
        try{
            foto.close();
        }catch(IOException e){
            e.printStackTrace();
        }
    }

    private void volverConsultar(){
        this.estado.setEstadoActual(Estado.CONSULTAR);
        //this.habilitarBotonesIME(true,false, false);
        this.habilitarBotonesIME(permisoEstudiante.isInsertar(), false, false);
        this.setHabilitarCampos(false);
        this.habilitarAceptarCancelar(false);
        this.cargarGridEstudiantes();
        this.txtFotoUrl.setText("");
    }
    /*
     * Obtiene todos los datos del estudiante y crea un objeto de tipo Estudiante
     * el cual es retornado
     */
    private Estudiante obtenerDatosEstudiante(){
        Estudiante estudiante = new Estudiante();
        estudiante.setNombre(this.txtNombre.getText());
        estudiante.setApellidos(this.txtApellidos.getText());
        estudiante.setCedula(this.txtCedula.getText());
        estudiante.setFecha_nac(obtenerFecha());
        estudiante.setSexo(this.cbSexo.getSelectedItem().toString().substring(0, 1));
        estudiante.setNacionalidad(this.txtNacionalidad.getText());
        estudiante.setEscuelaProcedencia(this.txtEscuelaProcedencia.getText());
        estudiante.setTelefono1(this.txtTelefono1.getText());
        estudiante.setTelefono2(this.txtTelefono2.getText());
        estudiante.setProvincia(this.txtProvincia.getText());
        estudiante.setCanton(this.txtCanton.getText());
        estudiante.setDistrito(this.txtDistrito.getText());
        estudiante.setOtrasSenias(this.txtOtrasSeñas.getText());
        estudiante.setAdecuacion1(this.cbAdeacuacion1.getSelectedItem().toString());
        estudiante.setAdecuacion2(this.cbAdeacuacion2.getSelectedItem().toString());
        estudiante.setProblemasSalud(this.txtProblemasSalud.getText());
        estudiante.setCondSocioAfectiva(this.txtCondSocioAfectiva.getText());
        estudiante.setCondSocioEconomica(this.txtCondSocioeconomica.getText());
        return estudiante;
    }

    private void consultarDatosEstudiante(String cedula){
        Estudiante estudiante = controladoraEstudiante.consultarEstudiante(cedula);
        if(estudiante != null){
            this.llenarCamposEstudiante(estudiante);
            InputStream foto = controladoraEstudiante.consultarFotoEstudiante(cedula);
            areaFoto.mostrarImagen(foto);
        }else{
            String mensaje = UtilidadesCapaNegocios.getErrorOperacion(UtilidadesCapaNegocios.moduloEstudiantes, UtilidadesCapaNegocios.opConsultar);
            JOptionPane.showMessageDialog(null, mensaje, "ERROR",JOptionPane.ERROR_MESSAGE);
        }
    }

    private void llenarCamposEstudiante(Estudiante estudiante){
        this.txtNombre.setText(estudiante.getNombre());
        this.txtApellidos.setText(estudiante.getApellidos());
        this.txtCedula.setText(estudiante.getCedula());
        Date fecha = estudiante.getFecha_nac();
        Calendar calendario = Calendar.getInstance();
        calendario.clear();
        calendario.setTime(fecha);
        this.spinDia.getModel().setValue(calendario.get(Calendar.DAY_OF_MONTH));
        this.spinMes.getModel().setValue(calendario.get(Calendar.MONTH) + 1);
        this.spinAño.getModel().setValue(calendario.get(Calendar.YEAR));
        this.txtEdad.setText(Integer.toString(UtilidadesCapaNegocios.obtenerEdad(calendario)));
        this.cbSexo.setSelectedItem(UtilidadesCapaNegocios.obtenerSexo(estudiante.getSexo()));
        this.txtNacionalidad.setText(estudiante.getNacionalidad());
        this.txtEscuelaProcedencia.setText(estudiante.getEscuelaProcedencia());
        this.txtTelefono1.setText(estudiante.getTelefono1());
        this.txtTelefono2.setText(estudiante.getTelefono2());
        this.txtProvincia.setText(estudiante.getProvincia());
        this.txtCanton.setText(estudiante.getCanton());
        this.txtDistrito.setText(estudiante.getDistrito());
        this.txtOtrasSeñas.setText(estudiante.getOtrasSenias());
        this.cbAdeacuacion1.setSelectedItem(estudiante.getAdecuacion1());
        this.cbAdeacuacion2.setSelectedItem(estudiante.getAdecuacion2());
        this.txtProblemasSalud.setText(estudiante.getProblemasSalud());
        this.txtCondSocioAfectiva.setText(estudiante.getCondSocioAfectiva());
        this.txtCondSocioeconomica.setText(estudiante.getCondSocioEconomica());
        this.habilitarBotonesIME(this.permisoEstudiante.isInsertar(), this.permisoEstudiante.isModificar(), this.permisoEstudiante.isEliminar());
    }

    private Date obtenerFecha(){
        Calendar calendario = this.obtenerCalendarioFecha();
        Date fecha = new Date(calendario.getTimeInMillis());
        return fecha;  
    }

	private Calendar obtenerCalendarioFecha(){
		int dia = Integer.parseInt(this.spinDia.getValue().toString());
        int mes = Integer.parseInt(this.spinMes.getValue().toString())-1;
        int año = Integer.parseInt(this.spinAño.getValue().toString());
        Calendar calendario = Calendar.getInstance();
        calendario.clear();
        calendario.set(año,mes,dia);
		return calendario;
	}

    private void cargarGridEstudiantes(){
        this.limpiarGridEstudiantes();
        if(this.permisoEstudiante.isConsultar()){
            LinkedList<Estudiante> estudiantes = controladoraEstudiante.consultarEstudiantes();
            Iterator<Estudiante> iterador = estudiantes.iterator();
            while(iterador.hasNext()){
                Estudiante estudiante = iterador.next();
                Object arregloDatos[] = new Object[3];
                arregloDatos[0] = estudiante.getCedula();
                arregloDatos[1] = estudiante.getNombre();
                arregloDatos[2] = estudiante.getApellidos();
                ((DefaultTableModel)this.gridEstudiantes.getModel()).addRow(arregloDatos);
            }
        }
    }//fin de cargarGridEstudiantes

    private void limpiarGridEstudiantes(){
        ((DefaultTableModel)this.gridEstudiantes.getModel()).setRowCount(0);
    }

    private boolean verificarDatosObligatorios(){
        boolean resultado = true;
        resultado &= !txtNombre.getText().trim().isEmpty();
        resultado &= !txtApellidos.getText().trim().isEmpty();
        resultado &= !txtCedula.getText().replaceAll("-", "").trim().isEmpty();
        if(!resultado){
            JOptionPane.showMessageDialog(null, "Los campos nombre, apellidos y N° cédula son obligatorios", "ERROR",JOptionPane.WARNING_MESSAGE);
        }
        return resultado;
    }

    private boolean validarDatos(){
        boolean resultado = true;
        resultado &= !txtCedula.getText().replaceAll("-", "").replaceAll("0", "").isEmpty();
        int dia = Integer.parseInt(this.spinDia.getValue().toString());
        int mes = Integer.parseInt(this.spinMes.getValue().toString())-1;
        int año = Integer.parseInt(this.spinAño.getValue().toString());
        Calendar calendario = Calendar.getInstance();
        calendario.clear();
        calendario.set(año,mes,dia);
        resultado &= (calendario.get(Calendar.DAY_OF_MONTH) == dia) && (calendario.get(Calendar.MONTH) == mes) && (calendario.get(Calendar.YEAR) == año);
        resultado &= this.verificarTamañoFoto();
        if(!resultado){
            String mensaje = "1.El número de cedula debe ser válido.\n2.Debe digitar una fecha válida.\n3. La foto no debe tener un tamaño mayor a 16MB";
            JOptionPane.showMessageDialog(null, mensaje, "ERROR",JOptionPane.WARNING_MESSAGE);
        }
        return resultado;
    }

    @Action
    public void insertandoEstudiante() {
        this.estado.setEstadoActual(Estado.INSERTAR);
        this.limpiarCampos();
        this.setHabilitarCampos(true);
        this.habilitarBotonesIME(false, false, false);
        this.habilitarAceptarCancelar(true);
    }

    @Action
    public void modificandoEstudiante() {
        this.estado.setEstadoActual(Estado.MODIFICAR);
        this.setHabilitarCampos(true);
        this.txtCedula.setEditable(false);
        this.habilitarBotonesIME(false, false, false);
        this.habilitarAceptarCancelar(true);
    }


    @Action
    public void eliminandoEstudiante() {
        Animador.animar();
        if(this.mostrarMensajeConfirmacion(UtilidadesCapaNegocios.opEliminar, "ELIMINAR")){
            this.eliminarEstudiante();
        }
        Animador.detenerAnimacion();
    }

    /**
     ** Muestra un mensaje de confirmación para que el usuario decida si realmente
     ** quiere llevar a cabo una operación
     ** @param operacion Código de operación realizada, tomada de UtilidadesCapaNegocios
     ** @param titulo Título a mostrar en el cuadro de confirmación
     ** @return Confirmación: true si el usuario acepta, false en otro caso.
     **/
    private boolean mostrarMensajeConfirmacion(int operacion,String titulo){
        boolean resultado = true;
        String mensaje = UtilidadesCapaNegocios.getMensajeConfirmacion(UtilidadesCapaNegocios.moduloEstudiantes, operacion);
        int respuesta = JOptionPane.showConfirmDialog(null, mensaje,titulo ,JOptionPane.YES_NO_OPTION,JOptionPane.WARNING_MESSAGE);
        resultado = respuesta == JOptionPane.OK_OPTION;
        return resultado;
    }//fin de mostrarMensajeConfirmacion

    @Action
    public void accionAceptar() {
        Animador.animar();
        switch(estado.getEstadoActual()){
            case Estado.INSERTAR:
                if(this.mostrarMensajeConfirmacion(UtilidadesCapaNegocios.opInsertar, "INSERTAR")){
                    if(verificarDatosObligatorios() && validarDatos()){
                        this.insertarEstudiante();
                    }
                }
            break;
            case Estado.MODIFICAR:
                if(this.mostrarMensajeConfirmacion(UtilidadesCapaNegocios.opModificar, "MODIFICAR")){
                    if(verificarDatosObligatorios() && validarDatos()){
                        this.modificarEstudiante();
                    }
                }
            break;
        }
        Animador.detenerAnimacion();
    }

    @Action
    public void accionCancelar() {
        this.limpiarCampos();
        this.volverConsultar();
    }

    @Action
    public void buscarEstudiante() {
        String cedulaBusqueda = txtCedulaBusqueda.getText();
        Estudiante estudiante = controladoraEstudiante.consultarEstudiante(cedulaBusqueda);
        if(estudiante != null){
            this.llenarCamposEstudiante(estudiante);
            String mensaje = "Se han cargado con éxito los datos del estudiante buscado";
            JOptionPane.showMessageDialog(null, mensaje, "Búsqueda exitosa",JOptionPane.INFORMATION_MESSAGE);
        }else{
            String mensaje = "El estudiante no se encuentra en el sistema";
            JOptionPane.showMessageDialog(null, mensaje, "ERROR",JOptionPane.ERROR_MESSAGE);
        }
    }

    @Action
    public void abriendoFoto() {
        JFileChooser ventana = new JFileChooser();
        ventana.setFileSelectionMode(JFileChooser.FILES_ONLY);
        ventana.setMultiSelectionEnabled(false);
        ventana.setFileView(new ImageFileView());
        ventana.setAccessory(new ImagePreview(ventana));
        ventana.removeChoosableFileFilter(ventana.getAcceptAllFileFilter());
        ventana.addChoosableFileFilter(new ImageFilter());

        int resultado = ventana.showOpenDialog(this);
        if(resultado == JFileChooser.APPROVE_OPTION){
            File archivoFoto = ventana.getSelectedFile();
            if(archivoFoto != null){
                this.txtFotoUrl.setText(archivoFoto.getAbsolutePath());
                FileInputStream foto = this.obtenerFoto();
                if(foto != null){
                    this.areaFoto.mostrarImagen(foto);
                    this.cerrarFoto(foto);
                }
            }
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        lbNombre = new javax.swing.JLabel();
        lbApellidos = new javax.swing.JLabel();
        txtNombre = new javax.swing.JTextField();
        txtApellidos = new javax.swing.JTextField();
        lbCedula = new javax.swing.JLabel();
        lbFechaNacimiento = new javax.swing.JLabel();
        lbSeparador1 = new javax.swing.JLabel();
        lbSeparador2 = new javax.swing.JLabel();
        lbSexo = new javax.swing.JLabel();
        cbSexo = new javax.swing.JComboBox();
        lbTelefono1 = new javax.swing.JLabel();
        lbTelefono2 = new javax.swing.JLabel();
        lbNacionalidad = new javax.swing.JLabel();
        txtNacionalidad = new javax.swing.JTextField();
        lbProvincia = new javax.swing.JLabel();
        txtProvincia = new javax.swing.JTextField();
        lbCanton = new javax.swing.JLabel();
        txtCanton = new javax.swing.JTextField();
        lbDistrito = new javax.swing.JLabel();
        txtDistrito = new javax.swing.JTextField();
        lbOtrasSenas = new javax.swing.JLabel();
        btnInsertar = new javax.swing.JButton();
        btnModificar = new javax.swing.JButton();
        btnEliminar = new javax.swing.JButton();
        txtCedula = new javax.swing.JFormattedTextField(createFormatter("#-####-####"));
        txtTelefono1 = new javax.swing.JFormattedTextField(createFormatter("##-##-##-##"));
        txtTelefono2 = new javax.swing.JFormattedTextField(createFormatter("##-##-##-##"));
        lbFoto = new javax.swing.JLabel();
        txtFotoUrl = new javax.swing.JTextField();
        btnExaminar = new javax.swing.JButton();
        lbAdeacuacion1 = new javax.swing.JLabel();
        cbAdeacuacion1 = new javax.swing.JComboBox();
        lbProblemasSalud = new javax.swing.JLabel();
        lbCondSocioEconomica = new javax.swing.JLabel();
        lbCondicionSocioafectiva = new javax.swing.JLabel();
        scrollTablaEstudiantes = new javax.swing.JScrollPane();
        gridEstudiantes = new javax.swing.JTable();
        btnCancelar = new javax.swing.JButton();
        btnAceptar = new javax.swing.JButton();
        lbAdeacuacion2 = new javax.swing.JLabel();
        cbAdeacuacion2 = new javax.swing.JComboBox();
        lbEscuelaProcedencia = new javax.swing.JLabel();
        txtEscuelaProcedencia = new javax.swing.JTextField();
        scrollOtrasSeñas = new javax.swing.JScrollPane();
        txtOtrasSeñas = new javax.swing.JTextArea();
        scrollProblemasSalud = new javax.swing.JScrollPane();
        txtProblemasSalud = new javax.swing.JTextArea();
        scrollCondSocioeconomica = new javax.swing.JScrollPane();
        txtCondSocioeconomica = new javax.swing.JTextArea();
        scrollCondSocioafectiva = new javax.swing.JScrollPane();
        txtCondSocioAfectiva = new javax.swing.JTextArea();
        spinMes = new javax.swing.JSpinner(new SpinnerNumberModel(1,1,12,1));
        spinDia = new javax.swing.JSpinner(new SpinnerNumberModel(1,1,31,1));
        spinAño = new javax.swing.JSpinner(new SpinnerNumberModel(1990,1900,2999,1));
        lbEdad = new javax.swing.JLabel();
        txtEdad = new javax.swing.JTextField();
        txtCedulaBusqueda = new javax.swing.JFormattedTextField(createFormatter("#-####-####"));
        btnBusqueda = new javax.swing.JButton();
        areaFoto = new adsec.presentacion.AreaFoto();
        obli1 = new javax.swing.JLabel();
        obli2 = new javax.swing.JLabel();
        obli3 = new javax.swing.JLabel();

        setMaximumSize(new java.awt.Dimension(740, 750));
        setMinimumSize(new java.awt.Dimension(740, 750));
        setName("Form"); // NOI18N
        setPreferredSize(new java.awt.Dimension(740, 750));

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(adsec.presentacion.LiceoEscazuApp.class).getContext().getResourceMap(PanelEstudiantes.class);
        lbNombre.setText(resourceMap.getString("lbNombre.text")); // NOI18N
        lbNombre.setName("lbNombre"); // NOI18N

        lbApellidos.setText(resourceMap.getString("lbApellidos.text")); // NOI18N
        lbApellidos.setName("lbApellidos"); // NOI18N

        txtNombre.setText(resourceMap.getString("txtNombre.text")); // NOI18N
        txtNombre.setAutoscrolls(false);
        txtNombre.setName("txtNombre"); // NOI18N

        txtApellidos.setText(resourceMap.getString("txtApellidos.text")); // NOI18N
        txtApellidos.setAutoscrolls(false);
        txtApellidos.setName("txtApellidos"); // NOI18N

        lbCedula.setText(resourceMap.getString("lbCedula.text")); // NOI18N
        lbCedula.setName("lbCedula"); // NOI18N

        lbFechaNacimiento.setText(resourceMap.getString("lbFechaNacimiento.text")); // NOI18N
        lbFechaNacimiento.setName("lbFechaNacimiento"); // NOI18N

        lbSeparador1.setText(resourceMap.getString("lbSeparador1.text")); // NOI18N
        lbSeparador1.setName("lbSeparador1"); // NOI18N

        lbSeparador2.setText(resourceMap.getString("lbSeparador2.text")); // NOI18N
        lbSeparador2.setName("lbSeparador2"); // NOI18N

        lbSexo.setText(resourceMap.getString("lbSexo.text")); // NOI18N
        lbSexo.setName("lbSexo"); // NOI18N

        cbSexo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Femenino", "Masculino" }));
        cbSexo.setName("cbSexo"); // NOI18N

        lbTelefono1.setText(resourceMap.getString("lbTelefono1.text")); // NOI18N
        lbTelefono1.setName("lbTelefono1"); // NOI18N

        lbTelefono2.setText(resourceMap.getString("lbTelefono2.text")); // NOI18N
        lbTelefono2.setName("lbTelefono2"); // NOI18N

        lbNacionalidad.setText(resourceMap.getString("lbNacionalidad.text")); // NOI18N
        lbNacionalidad.setName("lbNacionalidad"); // NOI18N

        txtNacionalidad.setText(resourceMap.getString("txtNacionalidad.text")); // NOI18N
        txtNacionalidad.setAutoscrolls(false);
        txtNacionalidad.setName("txtNacionalidad"); // NOI18N

        lbProvincia.setText(resourceMap.getString("lbProvincia.text")); // NOI18N
        lbProvincia.setName("lbProvincia"); // NOI18N

        txtProvincia.setText(resourceMap.getString("txtProvincia.text")); // NOI18N
        txtProvincia.setAutoscrolls(false);
        txtProvincia.setName("txtProvincia"); // NOI18N

        lbCanton.setText(resourceMap.getString("lbCanton.text")); // NOI18N
        lbCanton.setName("lbCanton"); // NOI18N

        txtCanton.setText(resourceMap.getString("txtCanton.text")); // NOI18N
        txtCanton.setAutoscrolls(false);
        txtCanton.setName("txtCanton"); // NOI18N

        lbDistrito.setText(resourceMap.getString("lbDistrito.text")); // NOI18N
        lbDistrito.setName("lbDistrito"); // NOI18N

        txtDistrito.setText(resourceMap.getString("txtDistrito.text")); // NOI18N
        txtDistrito.setAutoscrolls(false);
        txtDistrito.setName("txtDistrito"); // NOI18N

        lbOtrasSenas.setText(resourceMap.getString("lbOtrasSenas.text")); // NOI18N
        lbOtrasSenas.setName("lbOtrasSenas"); // NOI18N

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(adsec.presentacion.LiceoEscazuApp.class).getContext().getActionMap(PanelEstudiantes.class, this);
        btnInsertar.setAction(actionMap.get("insertandoEstudiante")); // NOI18N
        btnInsertar.setText(resourceMap.getString("btnInsertar.text")); // NOI18N
        btnInsertar.setName("btnInsertar"); // NOI18N

        btnModificar.setAction(actionMap.get("modificandoEstudiante")); // NOI18N
        btnModificar.setText(resourceMap.getString("btnModificar.text")); // NOI18N
        btnModificar.setName("btnModificar"); // NOI18N

        btnEliminar.setAction(actionMap.get("eliminandoEstudiante")); // NOI18N
        btnEliminar.setText(resourceMap.getString("btnEliminar.text")); // NOI18N
        btnEliminar.setName("btnEliminar"); // NOI18N

        txtCedula.setText(resourceMap.getString("txtCedula.text")); // NOI18N
        txtCedula.setName("txtCedula"); // NOI18N

        txtTelefono1.setText(resourceMap.getString("txtTelefono1.text")); // NOI18N
        txtTelefono1.setName("txtTelefono1"); // NOI18N

        txtTelefono2.setText(resourceMap.getString("txtTelefono2.text")); // NOI18N
        txtTelefono2.setName("txtTelefono2"); // NOI18N

        lbFoto.setText(resourceMap.getString("lbFoto.text")); // NOI18N
        lbFoto.setName("lbFoto"); // NOI18N

        txtFotoUrl.setEditable(false);
        txtFotoUrl.setText(resourceMap.getString("txtFotoUrl.text")); // NOI18N
        txtFotoUrl.setName("txtFotoUrl"); // NOI18N

        btnExaminar.setAction(actionMap.get("abriendoFoto")); // NOI18N
        btnExaminar.setText(resourceMap.getString("btnExaminar.text")); // NOI18N
        btnExaminar.setName("btnExaminar"); // NOI18N

        lbAdeacuacion1.setText(resourceMap.getString("lbAdeacuacion1.text")); // NOI18N
        lbAdeacuacion1.setName("lbAdeacuacion1"); // NOI18N

        cbAdeacuacion1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Ninguna", "Acceso", "Significativa", "No significativa" }));
        cbAdeacuacion1.setMaximumSize(new java.awt.Dimension(97, 20));
        cbAdeacuacion1.setMinimumSize(new java.awt.Dimension(97, 20));
        cbAdeacuacion1.setName("cbAdeacuacion1"); // NOI18N

        lbProblemasSalud.setText(resourceMap.getString("lbProblemasSalud.text")); // NOI18N
        lbProblemasSalud.setName("lbProblemasSalud"); // NOI18N

        lbCondSocioEconomica.setText(resourceMap.getString("lbCondSocioEconomica.text")); // NOI18N
        lbCondSocioEconomica.setName("lbCondSocioEconomica"); // NOI18N

        lbCondicionSocioafectiva.setText(resourceMap.getString("lbCondicionSocioafectiva.text")); // NOI18N
        lbCondicionSocioafectiva.setName("lbCondicionSocioafectiva"); // NOI18N

        scrollTablaEstudiantes.setName("scrollTablaEstudiantes"); // NOI18N

        gridEstudiantes.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Cédula", "Nombre", "Apellidos"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        scrollTablaEstudiantes.setViewportView(gridEstudiantes);
        gridEstudiantes.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        gridEstudiantes.getSelectionModel().addListSelectionListener(this);

        btnCancelar.setAction(actionMap.get("accionCancelar")); // NOI18N
        btnCancelar.setText(resourceMap.getString("btnCancelar.text")); // NOI18N
        btnCancelar.setName("btnCancelar"); // NOI18N

        btnAceptar.setAction(actionMap.get("accionAceptar")); // NOI18N
        btnAceptar.setText(resourceMap.getString("btnAceptar.text")); // NOI18N
        btnAceptar.setName("btnAceptar"); // NOI18N

        lbAdeacuacion2.setText(resourceMap.getString("lbAdeacuacion2.text")); // NOI18N
        lbAdeacuacion2.setName("lbAdeacuacion2"); // NOI18N

        cbAdeacuacion2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Ninguna", "Acceso", "Significativa", "No significativa" }));
        cbAdeacuacion2.setMaximumSize(new java.awt.Dimension(97, 20));
        cbAdeacuacion2.setMinimumSize(new java.awt.Dimension(97, 20));
        cbAdeacuacion2.setName("cbAdeacuacion2"); // NOI18N

        lbEscuelaProcedencia.setText(resourceMap.getString("lbEscuelaProcedencia.text")); // NOI18N
        lbEscuelaProcedencia.setName("lbEscuelaProcedencia"); // NOI18N

        txtEscuelaProcedencia.setText(resourceMap.getString("txtEscuelaProcedencia.text")); // NOI18N
        txtEscuelaProcedencia.setName("txtEscuelaProcedencia"); // NOI18N

        scrollOtrasSeñas.setName("scrollOtrasSeñas"); // NOI18N

        txtOtrasSeñas.setColumns(20);
        txtOtrasSeñas.setRows(5);
        txtOtrasSeñas.setMaximumSize(new java.awt.Dimension(166, 96));
        txtOtrasSeñas.setMinimumSize(new java.awt.Dimension(166, 96));
        txtOtrasSeñas.setName("txtOtrasSeñas"); // NOI18N
        txtOtrasSeñas.setPreferredSize(new java.awt.Dimension(166, 96));
        scrollOtrasSeñas.setViewportView(txtOtrasSeñas);

        scrollProblemasSalud.setName("scrollProblemasSalud"); // NOI18N

        txtProblemasSalud.setColumns(20);
        txtProblemasSalud.setRows(5);
        txtProblemasSalud.setMinimumSize(new java.awt.Dimension(164, 94));
        txtProblemasSalud.setName("txtProblemasSalud"); // NOI18N
        scrollProblemasSalud.setViewportView(txtProblemasSalud);

        scrollCondSocioeconomica.setName("scrollCondSocioeconomica"); // NOI18N

        txtCondSocioeconomica.setColumns(20);
        txtCondSocioeconomica.setRows(5);
        txtCondSocioeconomica.setMinimumSize(new java.awt.Dimension(164, 94));
        txtCondSocioeconomica.setName("txtCondSocioeconomica"); // NOI18N
        scrollCondSocioeconomica.setViewportView(txtCondSocioeconomica);

        scrollCondSocioafectiva.setName("scrollCondSocioafectiva"); // NOI18N

        txtCondSocioAfectiva.setColumns(20);
        txtCondSocioAfectiva.setRows(5);
        txtCondSocioAfectiva.setMinimumSize(new java.awt.Dimension(164, 94));
        txtCondSocioAfectiva.setName("txtCondSocioAfectiva"); // NOI18N
        scrollCondSocioafectiva.setViewportView(txtCondSocioAfectiva);

        spinMes.setToolTipText(resourceMap.getString("spinMes.toolTipText")); // NOI18N
        spinMes.setName("spinMes"); // NOI18N
        this.spinMes.addChangeListener(this);

        spinDia.setToolTipText(resourceMap.getString("spinDia.toolTipText")); // NOI18N
        spinDia.setName("spinDia"); // NOI18N
        this.spinDia.addChangeListener(this);

        spinAño.setToolTipText(resourceMap.getString("spinAño.toolTipText")); // NOI18N
        spinAño.setName("spinAño"); // NOI18N
        this.spinAño.addChangeListener(this);

        lbEdad.setText(resourceMap.getString("lbEdad.text")); // NOI18N
        lbEdad.setName("lbEdad"); // NOI18N

        txtEdad.setEditable(false);
        txtEdad.setText(resourceMap.getString("txtEdad.text")); // NOI18N
        txtEdad.setName("txtEdad"); // NOI18N

        txtCedulaBusqueda.setText(resourceMap.getString("txtCedulaBusqueda.text")); // NOI18N
        txtCedulaBusqueda.setName("txtCedulaBusqueda"); // NOI18N

        btnBusqueda.setAction(actionMap.get("buscarEstudiante")); // NOI18N
        btnBusqueda.setIcon(resourceMap.getIcon("btnBusqueda.icon")); // NOI18N
        btnBusqueda.setText(resourceMap.getString("btnBusqueda.text")); // NOI18N
        btnBusqueda.setName("btnBusqueda"); // NOI18N

        areaFoto.setBorder(new javax.swing.border.LineBorder(resourceMap.getColor("areaFoto.border.lineColor"), 5, true)); // NOI18N
        areaFoto.setName("areaFoto"); // NOI18N
        areaFoto.setPreferredSize(new java.awt.Dimension(140, 160));

        javax.swing.GroupLayout areaFotoLayout = new javax.swing.GroupLayout(areaFoto);
        areaFoto.setLayout(areaFotoLayout);
        areaFotoLayout.setHorizontalGroup(
            areaFotoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 130, Short.MAX_VALUE)
        );
        areaFotoLayout.setVerticalGroup(
            areaFotoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 150, Short.MAX_VALUE)
        );

        obli1.setForeground(resourceMap.getColor("obli1.foreground")); // NOI18N
        obli1.setText(resourceMap.getString("obli1.text")); // NOI18N
        obli1.setName("obli1"); // NOI18N

        obli2.setForeground(resourceMap.getColor("obli2.foreground")); // NOI18N
        obli2.setText(resourceMap.getString("obli2.text")); // NOI18N
        obli2.setName("obli2"); // NOI18N

        obli3.setForeground(resourceMap.getColor("obli3.foreground")); // NOI18N
        obli3.setText(resourceMap.getString("obli3.text")); // NOI18N
        obli3.setName("obli3"); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lbCondicionSocioafectiva, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(lbCondSocioEconomica, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(lbProblemasSalud, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(lbAdeacuacion1, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(lbFoto, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(lbOtrasSenas, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(lbProvincia, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(lbTelefono1, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(lbEscuelaProcedencia, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(lbNacionalidad, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(lbSexo, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(lbFechaNacimiento, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(lbCedula, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(lbApellidos, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(lbNombre, javax.swing.GroupLayout.Alignment.TRAILING))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(txtNombre, javax.swing.GroupLayout.PREFERRED_SIZE, 218, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(obli1))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(txtApellidos, javax.swing.GroupLayout.PREFERRED_SIZE, 261, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(obli2))
                    .addComponent(cbSexo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtNacionalidad, javax.swing.GroupLayout.PREFERRED_SIZE, 154, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtEscuelaProcedencia, javax.swing.GroupLayout.PREFERRED_SIZE, 341, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(txtTelefono1, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lbTelefono2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtTelefono2, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(txtProvincia, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lbCanton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtCanton, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lbDistrito)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtDistrito, javax.swing.GroupLayout.PREFERRED_SIZE, 128, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(scrollOtrasSeñas, javax.swing.GroupLayout.DEFAULT_SIZE, 460, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(txtFotoUrl, javax.swing.GroupLayout.PREFERRED_SIZE, 193, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnExaminar))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(cbAdeacuacion1, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lbAdeacuacion2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cbAdeacuacion2, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(scrollProblemasSalud, javax.swing.GroupLayout.DEFAULT_SIZE, 460, Short.MAX_VALUE)
                    .addComponent(scrollCondSocioeconomica, javax.swing.GroupLayout.DEFAULT_SIZE, 460, Short.MAX_VALUE)
                    .addComponent(scrollCondSocioafectiva, javax.swing.GroupLayout.DEFAULT_SIZE, 460, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(spinDia, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lbSeparador1)
                        .addGap(8, 8, 8)
                        .addComponent(spinMes, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(12, 12, 12)
                        .addComponent(lbSeparador2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(spinAño, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(lbEdad)
                        .addGap(2, 2, 2)
                        .addComponent(txtEdad, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(txtCedula, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(obli3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 351, Short.MAX_VALUE)))
                .addGap(148, 148, 148))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(areaFoto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(21, 21, 21)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addComponent(txtCedulaBusqueda, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(btnBusqueda, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 384, Short.MAX_VALUE)
                                .addComponent(btnAceptar)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(btnCancelar))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(btnInsertar)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(btnModificar)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(btnEliminar))
                            .addComponent(scrollTablaEstudiantes, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 665, Short.MAX_VALUE))))
                .addGap(54, 54, 54))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnEliminar)
                    .addComponent(btnModificar)
                    .addComponent(btnInsertar))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(34, 34, 34)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(lbNombre)
                            .addComponent(txtNombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(obli1))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(lbApellidos)
                            .addComponent(txtApellidos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(obli2))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(lbCedula)
                            .addComponent(txtCedula, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(obli3))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(spinDia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lbSeparador1)
                            .addComponent(spinMes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lbSeparador2)
                            .addComponent(spinAño, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lbEdad)
                            .addComponent(lbFechaNacimiento)
                            .addComponent(txtEdad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(cbSexo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lbSexo))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtNacionalidad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lbNacionalidad))
                        .addGap(6, 6, 6)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(lbEscuelaProcedencia)
                            .addComponent(txtEscuelaProcedencia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(lbTelefono1)
                            .addComponent(txtTelefono1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lbTelefono2)
                            .addComponent(txtTelefono2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(areaFoto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(lbProvincia)
                    .addComponent(txtProvincia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbCanton)
                    .addComponent(txtCanton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbDistrito)
                    .addComponent(txtDistrito, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(lbOtrasSenas)
                    .addComponent(scrollOtrasSeñas, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(lbFoto)
                    .addComponent(txtFotoUrl, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnExaminar))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(lbAdeacuacion1)
                    .addComponent(cbAdeacuacion1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbAdeacuacion2)
                    .addComponent(cbAdeacuacion2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(scrollProblemasSalud, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbProblemasSalud))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(lbCondSocioEconomica)
                    .addComponent(scrollCondSocioeconomica, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(lbCondicionSocioafectiva)
                    .addComponent(scrollCondSocioafectiva, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(12, 12, 12)
                .addComponent(scrollTablaEstudiantes, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(txtCedulaBusqueda, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(btnBusqueda, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(btnCancelar)
                        .addComponent(btnAceptar)))
                .addContainerGap(29, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private adsec.presentacion.AreaFoto areaFoto;
    private javax.swing.JButton btnAceptar;
    private javax.swing.JButton btnBusqueda;
    private javax.swing.JButton btnCancelar;
    private javax.swing.JButton btnEliminar;
    private javax.swing.JButton btnExaminar;
    private javax.swing.JButton btnInsertar;
    private javax.swing.JButton btnModificar;
    private javax.swing.JComboBox cbAdeacuacion1;
    private javax.swing.JComboBox cbAdeacuacion2;
    private javax.swing.JComboBox cbSexo;
    private javax.swing.JTable gridEstudiantes;
    private javax.swing.JLabel lbAdeacuacion1;
    private javax.swing.JLabel lbAdeacuacion2;
    private javax.swing.JLabel lbApellidos;
    private javax.swing.JLabel lbCanton;
    private javax.swing.JLabel lbCedula;
    private javax.swing.JLabel lbCondSocioEconomica;
    private javax.swing.JLabel lbCondicionSocioafectiva;
    private javax.swing.JLabel lbDistrito;
    private javax.swing.JLabel lbEdad;
    private javax.swing.JLabel lbEscuelaProcedencia;
    private javax.swing.JLabel lbFechaNacimiento;
    private javax.swing.JLabel lbFoto;
    private javax.swing.JLabel lbNacionalidad;
    private javax.swing.JLabel lbNombre;
    private javax.swing.JLabel lbOtrasSenas;
    private javax.swing.JLabel lbProblemasSalud;
    private javax.swing.JLabel lbProvincia;
    private javax.swing.JLabel lbSeparador1;
    private javax.swing.JLabel lbSeparador2;
    private javax.swing.JLabel lbSexo;
    private javax.swing.JLabel lbTelefono1;
    private javax.swing.JLabel lbTelefono2;
    private javax.swing.JLabel obli1;
    private javax.swing.JLabel obli2;
    private javax.swing.JLabel obli3;
    private javax.swing.JScrollPane scrollCondSocioafectiva;
    private javax.swing.JScrollPane scrollCondSocioeconomica;
    private javax.swing.JScrollPane scrollOtrasSeñas;
    private javax.swing.JScrollPane scrollProblemasSalud;
    private javax.swing.JScrollPane scrollTablaEstudiantes;
    private javax.swing.JSpinner spinAño;
    private javax.swing.JSpinner spinDia;
    private javax.swing.JSpinner spinMes;
    private javax.swing.JTextField txtApellidos;
    private javax.swing.JTextField txtCanton;
    private javax.swing.JFormattedTextField txtCedula;
    private javax.swing.JFormattedTextField txtCedulaBusqueda;
    private javax.swing.JTextArea txtCondSocioAfectiva;
    private javax.swing.JTextArea txtCondSocioeconomica;
    private javax.swing.JTextField txtDistrito;
    private javax.swing.JTextField txtEdad;
    private javax.swing.JTextField txtEscuelaProcedencia;
    private javax.swing.JTextField txtFotoUrl;
    private javax.swing.JTextField txtNacionalidad;
    private javax.swing.JTextField txtNombre;
    private javax.swing.JTextArea txtOtrasSeñas;
    private javax.swing.JTextArea txtProblemasSalud;
    private javax.swing.JTextField txtProvincia;
    private javax.swing.JFormattedTextField txtTelefono1;
    private javax.swing.JFormattedTextField txtTelefono2;
    // End of variables declaration//GEN-END:variables
    // </editor-fold>
}
